require 'tk'

root = TkRoot.new


TkLabel.new{
	text "双击改变listbox字体"
	#pack side:"top"
	grid row:0,sticky:"ns"
}


var = TkVariable.new
var.value_type = :Array
#var.element_value_type = :String
var.value = TkFont.families.sort
scroll = TkScrollbar.new{
	#command{
	#	->(*args){list.yview(*args)}
	#}
	orient 'vertical'
	grid row:1,column:1,sticky:"ns"
}

list = TkListbox.new{
	listvariable var
	font "* 20"
	#pack side:"bottom"
	grid row:1,column:0,sticky:"nsew"
	#yscrollcommand {
		#scroll set
	#	->(first,last){scroll.set(first,last)}
	#}
}
list.yscrollcommand(->(first,last){puts "#{first},#{last}";scroll.set(first,last)})
#list.yscrollcommand(proc {|first,last|scroll.set(first,last)})
scroll.command(->(*args){list.yview(*args)})
#scroll.command(proc {|*args|list.yview(*args)})

list.bind("Double-Button-1"){
	#puts var.value[list.curselection[0]]
	sel_idx = list.curselection[0]
	list.itemconfigure(sel_idx,foreground:"red")
	sf = "\"#{var.lget(sel_idx)}\" 20"
	puts sf
	#list.configure(font:var.value[list.curselection])
	list.configure(font:sf)
}


Tk.mainloop